#ifndef ILOGGER_H
#define ILOGGER_H

#include <string>
#include <sstream>
using namespace std;

//!Interface class of Loggers component.
class ILogger
{
public:
	//!Destructor.
	virtual ~ILogger(void){};

	//!Return itself to chain logs.
	/*!
	\return Return the this pointer.
	*/
	virtual ILogger& Log()=0;

	//!Write data in the old C format.
	/*!
	\param Format string containing the text to display
	\param ... data to write.
	*/
	void Log(const char* Format, ...);

	//!Operator << used to write as in a cout.
	/*!
	\param ToLog text to write.
	\return The reference to the logger that can be used to chains outputs.
	*/
	template <class T> ILogger& operator <<(const T& ToLog);

private:
	//!Write the string.
	/*!
	\param log The string to write.
	*/
	virtual void write(const string& log)const=0;   

};

template <class T> ILogger& ILogger::operator <<(const T& ToLog)
{
	ostringstream Stream;
    Stream << ToLog;
    write(Stream.str());

    return Log();
}

#endif
